﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI.WebControls;
using VK.Comm;
using VK.Comm.TransactSql;
using VK.Casemeet.Areas;

namespace VK.Casemeet.Merchants
{
    public static class ShopHelper
    {
        #region 企业类型
        public static ListItem[] TypeData = new ListItem[9]{
            new ListItem("户外俱乐部", "1"),
            new ListItem("户外厂商", "2"),
            new ListItem("高校社团", "3"),
            new ListItem("户外景点", "4"),
            new ListItem("户外环保", "5"),
            new ListItem("户外公益", "6"),
            new ListItem("户外培训", "7"),
            new ListItem("户外救援", "8"),
            new ListItem("其他", "9")
        };

        public static void BindTypeDDL(DropDownList control, OptionType optionType)
        {
            control.Items.Clear();
            control.Items.AddRange(TypeData);
            switch (optionType)
            {
                case OptionType.Default: break;
                case OptionType.Search: control.Items.Insert(0, new ListItem("全部", "0")); break;
                case OptionType.Select: control.Items.Insert(0, new ListItem("请选择", "0")); break;
            }
            control.SelectedIndex = 0;
        }

        public static string GetTypeLabel(int type)
        {
            string result = string.Empty;
            var items = TypeData.Where(p => p.Value == type.ToString());
            if (items.Count() > 0)
            {
                result = items.First().Text;
            }
            return result;
        }
        #endregion

        public static void BindLevelRAD(RadioButtonList control)
        {
            control.Items.Clear();
            control.Items.Add(new ListItem("普通会员", "1"));
            control.Items.Add(new ListItem("高级会员", "2"));
            control.SelectedIndex = 0;
        }

        public static string GetLevelLabel(int state)
        {
            string result = string.Empty;
            switch (state)
            {
                case 1: result = "普通会员"; break;
                case 2: result = "高级会员"; break;
            }
            return result;
        }

        public static void BindStateDDL(DropDownList control, OptionType optionType)
        {
            control.Items.Clear();
            control.Items.Add(new ListItem("启用", "1"));
            control.Items.Add(new ListItem("停用", "2"));
            control.Items.Add(new ListItem("待审核", "3"));
            control.SelectedIndex = 0;
        }

        public static string GetStateLabel(int state)
        {
            string result = string.Empty;
            switch (state)
            {
                case 1: result = "启用"; break;
                case 2: result = "停用"; break;
                case 3: result = "待审核"; break;
            }
            return result;
        }

        public static string GetIsCertificationLabel(bool isCertification)
        {
            string result = string.Empty;
            if (isCertification)
            {
                result = "已认证";
            }
            else
            {
                result = "未认证";
            }
            return result;
        }

        public static void BindAreaDDL(DropDownList ddl, OptionType optionType)
        {
            ddl.Items.Clear();
            ddl.DataSource = AreaBLL.GetAreaArray(0);
            ddl.DataTextField = "Name";
            ddl.DataValueField = "AreaID";
            ddl.DataBind();
            switch (optionType)
            {
                case OptionType.Default: break;
                case OptionType.Search: ddl.Items.Insert(0, new ListItem("全部", "0")); break;
                case OptionType.Select: ddl.Items.Insert(0, new ListItem("请选择", "0")); break;
            }
            ddl.SelectedIndex = 0;
        }
    }
}
